//这个模块对API进行统一管理

import requests from "./ajax";
import mockRequests from "./mockAjax";
// 三级联动
// 地址: /api/product/getBaseCategoryList  方式：get  参数：无
// 发请求 axios发送请求返回Promise
export const reqCategoryList = ()=> requests({url:'/product/getBaseCategoryList',method:'get'})

//获取轮播
export const reqBannerList = ()=> mockRequests({url:'/mock/banner',method:'get'})

//获取floor数据
export const reqFloorList = ()=> mockRequests({url:'/mock/floor',method:'get'})

//获取搜索模块的数据
//post请求后端数据，这里接口要求携带参数
/*
{
  "category3Id": "61",
  "categoryName": "手机",
  "keyword": "小米",
  "order": "1:desc",
  "pageNo": 1,
  "pageSize": 10,
  "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
  "trademark": "4:小米"
}
*/
//当前接口给服务器传递一个默认参数【至少是一个空对象】
export const reqGetSearchInfo = (params)=> requests({url:'/list',method:'post',data:params})

//获取产品详情
export const reqGetGoodsInfo = (skuId)=> requests({url:`/item/${skuId}`,method:'get'})

//将产品添加到购物车 post
export const reqAddOrUpdateShopCart = (skuId,skuNum)=>requests({url:`/cart/addToCart/${skuId}/${skuNum}`,method:"post"})

//获取购物车列表
export const reqGetCartList = ()=> requests({url:'/cart/cartList',method:'get'})

//删除产品
export const reqDeleteCart = (skuId)=>requests({url:`/cart/deleteCart/${skuId}`,method:'delete'})

//改变产品选中状态 /api/cart/checkCart/{skuId}/{isChecked} get
export const reqcheckCart = (skuId,isChecked)=>requests({url:`/cart/checkCart/${skuId}/${isChecked}`,method:"get"})

//获取验证码
export const reqGetCode = (phone)=>requests({url:`/user/passport/sendCode/${phone}`,method:'get'})

//注册
export const reqUserRegister = (data)=>requests({url:"/user/passport/register",method:'post',data})

//登录
export const reqUserLogin = (data)=>requests({url:'/user/passport/login',method:'post',data})

//获取用户信息
export const reqUserInfo = () => requests({url:'/user/passport/auth/getUserInfo',method:'get'})

//退出登录
export const reqLogout = ()=>requests({url:'/user/passport/logout',method:'get'})


//获取用户信息
export const reqAddressInfo = ()=>requests({url:'/user/userAddress/auth/findUserAddressList',method:'get'})

//获取交易页信息
export const reqOrderInfo = ()=>requests({url:'/order/auth/trade',method:'get'})

//提交订单
// url:/api/order/auth/submitOrder?tradeNo={tradeNo}
export const reqSubmitOrder = (tradeNo,data)=>requests({url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,method:'post',data}) 

//获取支付信息
// url:/payment/weixin/createNative/{orderId}
export const reqPayInfo = (orderId)=>requests({url:`/payment/weixin/createNative/${orderId}`,method:'get'})

//获取支付状态
export const reqPayStates = (orderId)=>requests({url:`/payment/weixin/queryPayStatus/${orderId}`,method:'get'})

//获取个人中心数据
// url:/api/order/auth/{page}/{limit}
export const reqCenterInfo =(page,limit)=>requests({url:`/order/auth/${page}/${limit}`,method:'get'})

